//
//  XMHTableViewCell.m
//  B段项目
//
//  Created by 徐茂怀 on 15/11/7.
//  Copyright © 2015年 徐茂怀. All rights reserved.
//

#import "XMHTableViewCell.h"
#import "FitHeader.h"
#import <UIImageView+WebCache.h>
@implementation XMHTableViewCell

-(instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        [self createView];
    }
    return self;
}
-(void)createView
{
    _myImageView = [[UIImageView alloc]init];
    [self.contentView addSubview:_myImageView];
    
    _titleLabel = [[UILabel alloc]init];
    _titleLabel.font = [UIFont fontWithName:@"EuphemiaUCAS-Bold" size:17 * FitWidth];
    [self.contentView addSubview:_titleLabel];
    
    _categoryLabel = [[UILabel alloc]init];
    _categoryLabel.font = [UIFont systemFontOfSize:15 * FitWidth];
    [self.contentView addSubview:_categoryLabel];
    
    _effectLabel = [[UILabel alloc]init];
    _effectLabel.font = [UIFont systemFontOfSize:15 * FitWidth];
    [self.contentView addSubview:_effectLabel];
    
    _ageLabel = [[UILabel alloc]init];
    _ageLabel.font = [UIFont systemFontOfSize:15 * FitWidth];
    [self.contentView addSubview:_ageLabel];
}

-(void)setModel:(NSXFirstPageListModel *)model
{
    [_myImageView sd_setImageWithURL:[NSURL URLWithString:model.thumb]];
    _titleLabel.text = model.title;
    _categoryLabel.text = [NSString stringWithFormat:@"分类:%@",model.category];
    _effectLabel.text = [NSString stringWithFormat:@"功效:%@",model.effect1];
    _ageLabel.text = [NSString stringWithFormat:@"人群:%@",model.age];
}

-(void)layoutSubviews
{
    [super layoutSubviews];
    _myImageView.frame = CGRectMake(5 * FitWidth, 5 * FitHeight, 140 * FitWidth, 90 *FitHeight);
    _titleLabel.frame = CGRectMake(150 * FitWidth, 5 *FitHeight, 180 *FitWidth, 20 *FitHeight);
    _categoryLabel.frame = CGRectMake(150 *FitWidth, 30 *FitHeight, 150 *FitWidth, 20 *FitHeight);
    _effectLabel.frame = CGRectMake(150 * FitWidth, 50 * FitHeight, 150 * FitWidth, 20 * FitHeight);
    _ageLabel.frame = CGRectMake(150 *FitWidth, 70 *FitHeight, 150 *FitWidth, 25 *FitHeight);
    
    //右三角
    UIImageView *rightImageView = [[UIImageView alloc]initWithFrame:CGRectMake(355 * FitWidth, 45 * FitHeight, 15 * FitWidth, 15 * FitHeight)];
    rightImageView.image = [UIImage imageNamed:@"iconfont-xiangyoujianjiao.png"];
    [self.contentView addSubview:rightImageView];
    
}

- (void)awakeFromNib {
    // Initialization code
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end
